fetch('http://chst.vip:1234/api/getcoupon')
.then(function(a){
    return a.json()
})
.then(function(b){
    console.log(b);
    let str = '';
    b.result.forEach(item => {
        str +=`<a couponId=${item.couponId}>
                    <img src=${item.couponImg} alt="" srcset="">
                    <p>${item.couponTitle}</p>
                </a>`
    });
    
    $('main').html(str);
})
.then(function(){
    $('main').on('click','a',function(){
        let couponId=$(this).attr('couponId')
        console.log(couponId);
        location.href='./couponproduct.html?couponId='+couponId
    })
})